package com.yfh.study.manager.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfh.data.base.utils.QfBeanUtils;
import com.yfh.data.system.dataManager.vo.input.ClassificationAddInput;
import com.yfh.data.system.entity.Classification;
import com.yfh.study.manager.dao.ClassificationDao;
import com.yfh.study.manager.service.ClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品分类表(Classification)表服务实现类
 *
 * @author makejava
 * @since 2022-09-10 08:45:17
 */
@Service("classificationService")
public class ClassificationServiceImpl extends ServiceImpl<ClassificationDao, Classification> implements ClassificationService {
    @Autowired
    private ClassificationDao classificationDao;


    /**
     * 查询所有分类
     * @return
     */
    @Override
    public List<Classification> getClassificationList() {
        return super.query().list();
    }

    /**
     * 添加分类
     * @param classificationAddInput
     * @return
     */
    @Override
    public boolean insertClassification(ClassificationAddInput classificationAddInput) {
        Classification classification = QfBeanUtils.beanCopy(classificationAddInput, Classification.class);
        return super.save(classification);
    }

    /**
     * 查询子级是否存在
     * @param id
     * @param type
     * @return
     */
    @Override
    public Integer queryByPid(Integer id, Integer type) {
        return classificationDao.queryByPid( id, type+1);
    }

    /**
     * 删除分类
     * @param id
     * @return
     */
    @Override
    public boolean deleteByid(Integer id) {
        return super.removeById(id);
    }


}

